#!/bin/bash

#------------------------------------------------------------------------------
#Filename:      74804-passwd.sh
#Version:       1.1
#Date:          2013/06/15
#Author:        yuanhui.shi
#Email:         yuanhui.shi@cs2c.com.cn
#Summary:       02.01系统核心功能-06基础命令行工具-12passwd工具-02passwd设置用户密码
#Notes:         通过passwd命令改变普通用户的密码
#Copyright:     China Standard Software Co.,Ltd.
#History:
#               Version 1.0,2013/07/30
#               -The first one
#               Version 1.1,2013/09/09
#               -Modify the script to satisfy the shell standard
#------------------------------------------------------------------------------
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh
source ./lib/Ssh.sh
source ../../lib/XmlParse.sh

function CleanData ()
{
  userdel -r ${USER}
  EchoInfo "74804-passwd.sh执行完毕"
}

trap "CleanData" EXIT

DATA_DIR="./data"
DATA_FILE="74804-passwd.xml"

XmlParse ${DATA_DIR}/${DATA_FILE}

GetValue USER USER
GetValue PASSWORD PASSWORD

EchoInfo "给普通用户$USER设置密码为${PASSWORD}"
Adduser ${USER} ${PASSWORD}


